﻿using System;
using System.Windows.Forms;

namespace Aker.Uretim
{
    public partial class StokKartiTipiSecici : XPopupForm
    {
        public StokKartiTipiSecici()
        {
            InitializeComponent();
        }

        public int StokKartiTipi;

        private void btnOk_Click(object sender, EventArgs e)
        {
            StokKartiTipi = radioGroup1.SelectedIndex + 1;
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnIptal_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        public static int GetStokKartiTipi(string Artikel)
        {
            int stokKartiTipi = -1;

            if (Artikel == "9773")
                stokKartiTipi = 1;
            else if (Artikel.StartsWith("11.") || Artikel.StartsWith("12.") || Artikel.StartsWith("30."))
                stokKartiTipi = 2;
            else if (Artikel.StartsWith("10.") || Artikel.StartsWith("20."))
                stokKartiTipi = 1;
            else if (!Artikel.Contains(".") &&
                (Artikel.StartsWith("5") || Artikel.StartsWith("7") || Artikel.StartsWith("8") || Artikel.StartsWith("9") || Artikel.StartsWith("95")))
                stokKartiTipi = 2;
            else
                using (StokKartiTipiSecici sks = new StokKartiTipiSecici())
                    if (sks.ShowDialog() == DialogResult.OK)
                        stokKartiTipi = sks.StokKartiTipi;

            return stokKartiTipi;
        }
    }
}